﻿using System;
using Newtonsoft.Json;

namespace TimeCard.Core
{
    /// <summary>
    /// 用户打卡规则
    /// </summary>
    public class UserRule
    {
        /// <summary>
        /// 规则主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 开始时
        /// </summary>
        public int StartHour { get; set; }

        /// <summary>
        /// 开始分
        /// </summary>
        public int StartMinute { get; set; }

        /// <summary>
        /// 结束时
        /// </summary>
        public int EndHour { get; set; }

        /// <summary>
        /// 结束分
        /// </summary>
        public int EndMinute { get; set; }

        /// <summary>
        /// 人员,逗号隔开
        /// </summary>
        public string Users { get; set; }

        /// <summary>
        /// 是否包含周末
        /// </summary>
        public bool HasWeekend { get; set; }

        [JsonIgnore]
        public string Display => $"{StartString} - {EndString} ({(HasWeekend ? "含周末" : "不含周末")})";

        /// <summary>
        /// 开始时分字符串
        /// </summary>
        [JsonIgnore]
        public string StartString => $"{StartHour:00}:{StartMinute:00}";

        /// <summary>
        /// 结束时分字符串
        /// </summary>
        [JsonIgnore]
        public string EndString => $"{EndHour:00}:{EndMinute:00}";

        /// <summary>返回表示当前对象的字符串。</summary>
        /// <returns>表示当前对象的字符串。</returns>
        /// <filterpriority>2</filterpriority>
        public override string ToString()
        {
            return $"{StartString} - {EndString}";
        }
    }
}